1.0 Field of the Invention
This invention relates to performance monitoring; and in particular, this invention relates to dynamically profiling consumption of CPU time in Java methods with respect to method line numbers while executing in a Java virtual machine.
2.0 Description of the Related Art
A Java application program executes in a Java virtual machine on a computer system. The Java virtual machine (JVM) is a software machine which executes on the hardware of a physical machine, that is, a computer system. In other words, the JVM is a software simulation of a machine. The JVM takes as its program input a stream of bytes, referred to as bytecode, that represent execution code provided by a programming language, then simulates that program's execution one bytecode at a time. Programs that are written in a language that produces the bytecode used by the JVM are called Java application programs.
Because the JVM is a simulated machine, Java application programs may not perform as efficiently as computer programs executed in the machine language of the computer system. This is due in part to the simulation and also in part to the nature of the Java language itself. As a language, Java removes the programmer from knowing any details of the hardware of the machine on which the Java application program executes; therefore, when designing the Java application program, the programmer may not be able to take advantage of the computer system's hardware, and in particular, any special features of the computer system's hardware. Because of these factors, Java application programs tend to consume large amounts of processor time. Therefore, it would be desirable to measure the amount of processor time, also referred to as central processing unit (CPU) time, consumed by a Java application program and redesign that Java application program if that consumption is excessive.
FIG. 1 depicts a portion of an exemplary Java application program 20. The program logic of the Java application program 20 comprises one or more Java instructions or statements 22. Each line of a Java application program 20 is associated with a line number 24. One or more Java statements may be on, that is associated with, a line and line number. A Java statement produces one or more bytecodes. The program logic of a Java application program 20 comprises one or more classes and each class comprises one or more Java methods. In this example, an exemplary Java method called handleNewConnection starts on line 401, and another exemplary Java method called hello starts on line 437. A Java method is invoked using its name and is ended at a return, for example, on lines numbered 412, 420 and 421, or at a break for example on line 433.
Conventional performance monitors typically measure the performance of Java application programs at the Java method level. Typically the performance monitor will determine the amount of time that a Java method consumes by computing the difference in time between when a Java method is entered and when the Java method is exited or ended. In addition, a Java method can wait during its execution. Therefore, measuring the amount of time that a Java method consumes by computing the difference in time between when the Java method is entered and exited is good for calculating Java application program delays, but may not accurately measure the amount of processor time consumed, that is, central processing unit (CPU) time consumption.
Within a Java method, some Java statements may consume more CPU time than other Java statements. The technique described above does not measure the CPU time consumption within a Java method. Therefore, there is a need for a technique that measures CPU time consumption within the Java method.